package implementation.sort;

import anaydis.sort.SorterType;
import com.sun.istack.internal.NotNull;

import java.util.Comparator;
import java.util.List;


public class ShellSorter extends HSort {
    List<Integer> sequence;

    public ShellSorter() {
        this(SorterType.SHELL);
    }

    protected ShellSorter(SorterType type) {
        super(type);
    }

    //orden ascendente
    public void setSequence(List<Integer> sequence) {
        this.sequence = sequence;
    }

    public <T> void sort(@NotNull Comparator<T> tComparator, @NotNull List<T> ts) {
        for (int i = sequence.size() - 1; i >= 0; i--) {
            if (sequence.get(i) < ts.size()) {
                setH(sequence.get(i));
                hSort(tComparator, ts);
            }
        }

        /*BubbleSort ss = new BubbleSort();
        for(int i=0; i<sorterListeners.size(); i++){
            ss.addSorterListener((SorterListener)sorterListeners.get(i));
        }
        ss.sort(tComparator, ts);*/
    }
}
